{eq name="'Index@theme_conf'|is_check_access" value="1"}
<style type="text/css">
    #theme_main_color,#theme_assist_color {
        /*margin:0;*/
        /*padding:0;*/
        border:solid 1px #ccc;
        width:70px;
        height:20px;
        border-right:40px solid green;
        /*line-height:20px;*/
    } 
</style>
<form class="form-horizontal" id="postForm1" action="{:url('Index/theme_conf')}" method="post">
    <div class="ncap-form-default">
        <dl class="row">
            <dt class="tit">
                <label for="login_logo">登录logo</label>
            </dt>
            <dd class="opt">
                <div class="input-file-show">
                    <span class="show">
                        <a id="img_a_login_logo" class="nyroModal" rel="gal" href="{$global.web_loginlogo|default='javascript:void(0);'}?t={php}echo getTime();{/php}" target="_blank">
                            <i id="img_i_login_logo" class="fa fa-picture-o" {notempty name="$global.web_loginlogo"}onmouseover="layer_tips=layer.tips('<img src={$global.web_loginlogo|default=''} class=\'layer_tips_img\'>',this,{tips: [1, '#fff']});"{/notempty} onmouseout="layer.close(layer_tips);"></i>
                        </a>
                    </span>
                    <span class="type-file-box">
                        <input type="text" id="login_logo" name="login_logo" value="{$global.web_loginlogo|default=''}" class="type-file-text" autocomplete="off">
                        <input type="button" name="button" id="button1" value="选择上传..." class="type-file-button">
                        <input class="type-file-file" onClick="GetUploadify(1,'','loginlogo','login_logo_call_back','{:url('Uploadimgnew/upload_full', ['width'=>180, 'height'=>60])}');" size="30" hidefocus="true" nc_type="change_site_logo" title="点击前方预览图可查看大图，点击按钮选择文件并提交表单后上传生效">
                    </span>
                </div>
                <span class="err"></span>
                <p class="notic"></p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label for="login_bgimg">背景图</label>
            </dt>
            <dd class="opt">
                <div class="input-file-show">
                    <span class="show">
                        <a id="img_a_login_bgimg" class="nyroModal" rel="gal" href="{$global.web_loginbgimg|default='javascript:void(0);'}" target="_blank">
                            <i id="img_i_login_bgimg" class="fa fa-picture-o" {notempty name="$global.web_loginbgimg"}onmouseover="layer_tips=layer.tips('<img src={$global.web_loginbgimg|default=''} class=\'layer_tips_img\'>',this,{tips: [1, '#fff']});"{/notempty} onmouseout="layer.close(layer_tips);"></i>
                        </a>
                    </span>
                    <span class="type-file-box">
                        <input type="text" id="login_bgimg" name="login_bgimg" value="{$global.web_loginbgimg|default=''}" class="type-file-text" autocomplete="off">
                        <input type="button" name="button" id="button1" value="选择上传..." class="type-file-button">
                        <input class="type-file-file" onClick="GetUploadify(1,'','loginbgimg','login_bgimg_call_back','{:url('Uploadimgnew/upload_full', ['width'=>1920, 'height'=>1080])}');" size="30" hidefocus="true" nc_type="change_site_logo" title="点击前方预览图可查看大图，点击按钮选择文件并提交表单后上传生效">
                    </span>
                </div>
                <span class="err"></span>
                <p class="notic"></p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label for="admin_logo">后台logo</label>
            </dt>
            <dd class="opt">
                <div class="input-file-show">
                    <span class="show">
                        <a id="img_a_admin_logo" class="nyroModal" rel="gal" href="{$global.web_adminlogo|default='javascript:void(0);'}?t={php}echo getTime();{/php}" target="_blank">
                            <i id="img_i_admin_logo" class="fa fa-picture-o" {notempty name="$global.web_adminlogo"}onmouseover="layer_tips=layer.tips('<img src={$global.web_adminlogo|default=''} class=\'layer_tips_img\'>',this,{tips: [1, '#fff']});"{/notempty} onmouseout="layer.close(layer_tips);"></i>
                        </a>
                    </span>
                    <span class="type-file-box">
                        <input type="text" id="admin_logo" name="admin_logo" value="{$global.web_adminlogo|default=''}" class="type-file-text" autocomplete="off">
                        <input type="button" name="button" id="button1" value="选择上传..." class="type-file-button">
                        <input class="type-file-file" onClick="GetUploadify(1,'','adminlogo','admin_logo_call_back','{:url('Uploadimgnew/upload_full', ['width'=>45, 'height'=>45])}');" size="30" hidefocus="true" nc_type="change_site_logo" title="点击前方预览图可查看大图，点击按钮选择文件并提交表单后上传生效">
                    </span>
                </div>
                <span class="err"></span>
                <p class="notic"></p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label for="web_ico">选项卡ico</label>
            </dt>
            <dd class="opt">
                <div class="input-file-show">
                    <span class="show">
                        <a id="img_a_web_ico" class="nyroModal" rel="gal" href="{$global.web_ico|default='javascript:void(0);'}?t={php}echo getTime();{/php}" target="_blank">
                            <i id="img_i_web_ico" class="fa fa-picture-o" {notempty name="$global.web_ico"}onmouseover="layer_tips=layer.tips('<img src={$global.web_ico|default=''}?t={php}echo time();{/php} width=32 height=32>',this,{tips: [1, '#fff']});"{/notempty} onmouseout="layer.close(layer_tips);"></i>
                        </a>
                    </span>
                    <span class="type-file-box">
                        <input type="text" id="web_ico" name="web_ico" value="{$global.web_ico|default=''}" class="type-file-text" autocomplete="off">
                        <input type="button" name="button" id="button1" value="选择上传..." class="type-file-button">
                        <input class="type-file-file" onClick="GetUploadify(1,'','ico','web_ico_img_call_back','{:url('Uploadimgnew/upload_full', ['width'=>32, 'height'=>32])}');" size="30" hidefocus="true" nc_type="change_site_logo" title="点击前方预览图可查看大图，点击按钮选择文件并提交表单后上传生效">
                    </span>
                </div>
                <span class="err"></span>
                <p class="notic">建议尺寸 32 * 32 (像素) 的.ico文件。<br/>如果无法正常显示新上传图标，清空浏览器缓存后访问。</p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label for="theme_id">主题风格</label>
            </dt>
            <dd class="opt">
                <div class="theme_style" id="theme_login_style">
                    <ul>
                        {volist name="$list" id="vo"}
                        <li class="curpoin">
                            <div onmouseover="upimgMouseover(this);" onmouseout="upimgMouseout(this);">
                                <img src="{$vo.theme_pic|get_default_pic=###}" class="theme_style_img {if condition="$vo['theme_id'] == $global['web_theme_styleid']"} active {/if}">
                                <div class="cover-bg" style="display: none;"></div>
                                <div class="icaction" style="display: none;">
                                    <span class="load_images" onclick="theme_style_edit(this);" data-theme_id="{$vo.theme_id}">
                                        <i class="fa fa-edit"></i>编辑
                                    </span>
                                    {if condition="$vo['is_system'] == 0"}
                                    <span class="load_images" onclick="theme_style_del(this);" data-theme_id="{$vo.theme_id}" data-is_system="{$vo['is_system']}" data-web_theme_styleid="{$global['web_theme_styleid']}">
                                        <i class="fa fa-trash"></i>删除
                                    </span>
                                    {/if}
                                </div>
                            </div>
                            <span class="span_theme_title"><input name="theme_id" value="{$vo.theme_id}" type="radio" {if condition="$vo['theme_id'] == $global['web_theme_styleid']"} checked="checked" {/if}><span id="css_tplname_{$vo['theme_id']}">{$vo.theme_title}</span></span>
                        </li>
                        {/volist}
                        <li class="curpoin" id="css_tplname">
                            <img src="__SKIN__/images/jia.png" style="border: 1px solid #eee; width: 138px; height: 98px;" onclick="theme_style_add(this);">
                        </li>
                    </ul>
                </div>
            </dd>
        </dl>
        <dl class="row">
            <div class="bot">
                <!-- <input type="hidden" name="theme_title" value="">
                <input type="hidden" name="is_select_theme" value="0"> -->
                <a href="JavaScript:void(0);" onclick="checkSubmit1();" class="ncap-btn-big ncap-btn-green" id="submitBtn">保存</a>
            </div>
        </dl>
    </div>
</form>

<script>
    $(document).ready(function(){

        // 主题风格切换
        $('#theme_login_style').find('.span_theme_title').click(function(){
            $('#theme_login_style').find('li>img.theme_style_img').removeClass('active');
            $(this).find('img.theme_style_img').addClass('active');
            $(this).find('input[type=radio]').prop('checked', true);
            /*var theme_id = $(this).find('input[type=radio]').val();
            $.ajax({
                type: "GET",
                url: "{:url('Index/ajax_get_theme_info', ['_ajax'=>1])}",
                data: {theme_id:theme_id},
                dataType: 'json',
                success: function (res) {
                    layer.closeAll();
                    if (res.code == 1) {
                        $('input[name=is_select_theme]').val(1);
                        var info = res.data.info;
                        $('input[name=theme_title]').val(info.theme_title);
                    } else {
                        showErrorAlert(res.msg);
                    }
                },
                error:function(e){
                    layer.closeAll();
                    showErrorAlert(e.responseText);
                }
            });*/
        });

        // 登录背景图切换
        $('.div_login_bgimg_model').find('li').click(function(){
            $('.div_login_bgimg_model').find('li').removeClass('active');
            $(this).addClass('active');
            var data_model = $(this).attr('data-model');
            $('#login_bgimg_model').val(data_model);
            if ('custom' == data_model) {
                $('#div_custom_login_bgimg').show();
            } else {
                $('#div_custom_login_bgimg').hide();
                // 登录背景图
                var loginbgimg = $(this).find('img').attr('src');
                $('#login_bgimg').val(loginbgimg);
            }
        });
    });

    // 鼠标事件，加载查看大图和更新图片
    function upimgMouseover(obj)
    {
        $(obj).parent().find('div.icaction').show();
        $(obj).parent().find('div.cover-bg').show();
    }
    function upimgMouseout(obj)
    {
        $(obj).parent().find('div.icaction').hide();
        $(obj).parent().find('div.cover-bg').hide();
    }

    function checkSubmit1(){
        layer_loading('正在处理');
        $.ajax({
            type : 'POST',
            url : "{:url('Index/theme_conf', ['_ajax'=>1])}",
            data : $('#postForm1').serialize(),
            dataType : 'json',
            success : function(res){
                if(res.code == 1){
                    if (res.data.is_change == 1) {
                        /*layer.confirm('已保存，确认要新建主题风格？', {
                            shade: layer_shade,
                            area: ['480px', '190px'],
                            move: false,
                            title: '提示',
                            btnAlign:'r',
                            closeBtn: 3,
                            btn: ['新建主题','关闭'], //按钮
                            success: function () {
                                $(".layui-layer-content").css('text-align', 'left');
                                $(".layui-layer-btn").find('a.layui-layer-btn1').removeClass('layui-layer-btn1').addClass('layui-layer-btn2');
                                $(".layui-layer-btn").find('a.layui-layer-btn0').removeClass('layui-layer-btn0').addClass('layui-layer-btn1');
                                $(".layui-layer-btn").find('a.layui-layer-btn2').removeClass('layui-layer-btn2').addClass('layui-layer-btn0');
                            },
                            cancel: function(index, layero){
                                layer.closeAll();
                                window.location.reload();
                                return false;
                            }
                        }, function () {
                            layer.closeAll();
                            layer.prompt({
                                title: '新建主题风格',
                                id: 'layerid_1645598368',
                                btn: ['确定','取消'],
                                shade: layer_shade,
                                closeBtn: 0,
                                success: function(layero, index) {
                                    $("#layerid_1645598368").find('input').attr('placeholder', '请输入主题名称');
                                    $("#layerid_1645598368").find('input').bind('keydown', function(event) {
                                        if (event.keyCode == 13) {
                                            theme_add_login($(this).val());
                                        }
                                    });
                                },
                                btn2: function(index, layero){
                                    window.location.reload();
                                    return false;
                                }
                            }, function(value, index) {
                                theme_add_login(value);
                            });
                        }, function (index) {
                            layer.closeAll();
                            window.location.reload();
                        });*/
                    } else {
                        layer.closeAll();
                        layer.alert(res.msg, {
                            shade: layer_shade,
                            area: ['480px', '190px'],
                            move: false,
                            title: '提示',
                            btnAlign:'r',
                            closeBtn: 3,
                            btn: ['立即刷新','关闭'],
                            success: function () {
                                $(".layui-layer-content").css('text-align', 'left');
                            },
                            cancel: function(index, layero){ 
                                window.location.reload();
                                return false; 
                            },
                            btn2: function(index, layero){
                                window.location.reload();
                            }
                        },function(){
                            top.window.location.reload();
                        });
                    }
                }else{
                    layer.closeAll();
                    showErrorMsg(res.msg);
                }
            },
            error: function(e){
                layer.closeAll();
                layer.alert(e.responseText, {icon: 5, title:false});
            }
        });
    }

    function admin_logo_call_back(fileurl_tmp)
    {
        $("#admin_logo").val(fileurl_tmp);
        $("#img_a_admin_logo").attr('href', fileurl_tmp);
        $("#img_i_admin_logo").attr('onmouseover', "layer_tips=layer.tips('<img src="+fileurl_tmp+" class=\\'layer_tips_img\\'>',this,{tips: [1, '#fff']});");
    }

    function login_logo_call_back(fileurl_tmp)
    {
        $("#login_logo").val(fileurl_tmp);
        $("#img_a_login_logo").attr('href', fileurl_tmp);
        $("#img_i_login_logo").attr('onmouseover', "layer_tips=layer.tips('<img src="+fileurl_tmp+" class=\\'layer_tips_img\\'>',this,{tips: [1, '#fff']});");
    }

    function login_bgimg_call_back(fileurl_tmp)
    {
        $("#login_bgimg").val(fileurl_tmp);
        $("#img_a_login_bgimg").attr('href', fileurl_tmp);
        $("#img_i_login_bgimg").attr('onmouseover', "layer_tips=layer.tips('<img src="+fileurl_tmp+" class=\\'layer_tips_img\\'>',this,{tips: [1, '#fff']});");
    }
    
    function web_ico_img_call_back(fileurl_tmp)
    {
        $("#web_ico").val(fileurl_tmp);
        $("#img_a_web_ico").attr('href', fileurl_tmp);
        $("#img_i_web_ico").attr('onmouseover', "layer_tips=layer.tips('<img src="+fileurl_tmp+" width=32 height=32>',this,{tips: [1, '#fff']});");
    }

    function theme_style_add(obj)
    {
        var url = "{:url('Index/ajax_theme_tplfile_add',['type'=>'css'])}";
        //iframe窗
        layer.open({
            type: 2,
            title: '新建主题风格',
            fixed: true, //不固定
            shadeClose: false,
            shade: layer_shade,
            maxmin: false, //开启最大化最小化按钮
            area: ['100%', '100%'],
            content: url
        });
    }

    function theme_style_edit(obj)
    {
        var theme_id = $(obj).data('theme_id');
        var url = "{:url('Index/ajax_theme_tplfile_edit',['type'=>'css'])}";
        if (url.indexOf('?') > -1) {
            url += '&';
        } else {
            url += '?';
        }
        url += 'theme_id='+theme_id;
        //iframe窗
        layer.open({
            type: 2,
            title: '编辑主题风格',
            fixed: true, //不固定
            shadeClose: false,
            shade: layer_shade,
            maxmin: false, //开启最大化最小化按钮
            area: ['100%', '100%'],
            content: url
        });
    }

    function theme_style_del(obj)
    {
        var theme_id = $(obj).attr('data-theme_id');
        var is_system = $(obj).attr('data-is_system');
        if (1 == is_system) {
            layer.msg('内置主题禁止删除！', {icon: 2, time:1500});
            return false;
        }
        var web_theme_styleid = $(obj).attr('data-web_theme_styleid');
        if (theme_id == web_theme_styleid) {
            layer.msg('当前主题正在使用，禁止删除！', {icon: 2, time:1500});
            return false;
        }

        layer.confirm('确定删除？', {
                shade: layer_shade,
                area: ['480px', '190px'],
                move: false,
                title: '提示',
                btnAlign:'r',
                closeBtn: 3,
                btn: ['确定', '取消'], //按钮
                success: function () {
                    $(".layui-layer-content").css('text-align', 'left');
                }
            }, function(){
                // 确定
                layer_loading('正在处理');
                $.ajax({
                    type : 'POST',
                    url : "{:url('Index/ajax_theme_tplfile_del',['type'=>'css'])}",
                    data : {theme_id:theme_id, _ajax:1},
                    dataType : 'json',
                    success : function(res){
                        layer.closeAll();
                        if(res.code == 1){
                            layer.msg(res.msg, {icon: 1, time:1000}, function(){
                                window.location.reload();
                            });
                        }else{
                            showErrorAlert(res.msg);
                        }
                    },
                    error:function(e){
                        layer.closeAll();
                        showErrorAlert(e.responseText);
                    }
                })
            }, function(index){
                layer.close(index);
                return false;// 取消
            }
        );
    }
</script>
{/eq}